home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / util / dumpStats.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  6.6 KB  |  208 lines

  1. /*
  2.  *   $RCSfile: dumpStats.C,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:56:03 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38. #include "sysdefs.h"
  39. #include "ess.h"
  40. #include "checking.h"
  41. #include "trace.h"
  42. #include "error.h"
  43. #include "io.h"
  44. #include "list.h"
  45. #include "tid.h"
  46. #include "lock.h"
  47. #include "object.h"
  48. #include "msgdefs.h"
  49. #include "thread.h"
  50. #include "semaphore.h"
  51. #include "link.h"
  52. #include "lsn.h"
  53. #include "latch.h"
  54. #include "bf.h"
  55. #include "volume.h"
  56. #include "trans.h"
  57. #include "bitvec.h"
  58. #include "openlog.h"
  59. #include "msgvector.h"
  60. #include "adminmsg.h"
  61. #include "msg_funcs.h"
  62. #include "thread_funcs.h"
  63. #include "server_util_funcs.h"
  64. #include "thread_globals.h"
  65. #include "msg_globals.h"
  66. #include "log_globals.h"
  67. #include "admin_globals.h"
  68. #include "stat_globals.h"
  69. #include "queue_consist.h"
  70. #include "timer.h"
  71.  
  72. extern int NumBuffers;                        /* ../bf/space.c */
  73. #if IO_STATISTICS IS_ENABLED
  74. extern int IO_DiskReads, IO_DiskWrites;        /* ../io/space.c */
  75. #endif
  76.  
  77. void
  78. dumpStats()
  79. {
  80.  
  81.     /*
  82.      *    Print server statistics collected by the admin facility
  83.      */
  84.     fprintf(stdout,"Number of Clients: %d, Number of Volumes: %d\n", ServerStats.numClients, ServerStats.numVolumes);
  85.     fprintf(stdout,"Transactions in progress: %d, Total Commits: %d, Total Aborts: %d\n", 
  86.             ServerStats.numTrans, ServerStats.totalCommits, ServerStats.totalAborts);
  87.     fprintf(stdout,"Total disk reads: %d, Total disk writes: %d\n", 
  88.             ServerStats.diskReads, ServerStats.diskWrites);
  89.     fprintf(stdout,"Free Log Space: %d, Checkpoint Freq: %d\n", 
  90.             ServerStats.freeLogSpace, ServerStats.chpntFreq);
  91.     fprintf(stdout,"\n");
  92. #ifdef DEBUG
  93.     fprintf(stderr, "Largest stack used: %d words.\n", LargestStack);
  94. #endif DEBUG
  95.  
  96. #ifdef DEBUG
  97.     { 
  98.         extern int loops, loop_spare, loop_ran_ready;
  99.  
  100.         fprintf(stdout,"LOOPS: %d loops, %d spare, %d ran_ready, %d selects\n", 
  101.             loops, loop_spare, loop_ran_ready, 
  102.             loops-(loop_spare+loop_ran_ready
  103.                 +disk_replies_found
  104.             ));
  105.     }
  106. #endif DEBUG
  107.     if(serv_sleeps + serv_sel_intrs == 0) {
  108.         fprintf(stdout,"NO SELECTS\n");
  109.     } else {
  110.         fprintf(stdout,
  111.         "SELECTS: %d, %d EINTR, %d connect, %d disk, %d client, %d stdin, %d media, %d dgram\n", 
  112.             serv_sleeps, serv_sel_intrs,
  113.             sel_connects, sel_disks, sel_clients, sel_stdin, sel_media,
  114.             sel_dgrams);
  115.         fprintf(stdout,"REPLIES (from SELECT.disk):\n");
  116.         fprintf(stdout," %d replies kicked,", disk_replies_kicked);
  117.         fprintf(stdout," %d replies found,", disk_replies_found);
  118.         fprintf(stdout," %d unnecessary kicks\n", unnecessary_kicks);
  119.         fprintf(stdout,"CACHE (from SELECT.client) : %d buffers\n", NumBuffers);
  120.         fprintf(stdout," %d hits, %d misses\n", cache_hits, cache_misses);
  121.     }
  122.  
  123. #if IO_STATISTICS IS_ENABLED
  124.     fprintf(stdout," %d IO_DiskReads, %d IO_DiskWrites\n", IO_DiskReads, IO_DiskWrites);
  125.     fprintf(stdout,"DISK MESSAGES (from CACHE.IO_Disk{Read,Write}s):\n");
  126. #else
  127.     fprintf(stdout,"DISK MESSAGES:\n");
  128. #endif IO_STATISTICS IS_ENABLED
  129.  
  130.     fprintf(stdout," %d requests, %d locally, %d remotely\n", 
  131.         disk_requests, fast_path_taken, slow_path_taken);
  132.  
  133.     fprintf(stdout,"QUEUES (from DISK MESSAGES.remotely):\n");
  134.     fprintf(stdout," %d outstanding disk requests,", disk_requests_out);
  135.     fprintf(stdout," %d waiting to write to q,", threads_awaiting_q);
  136.     fprintf(stdout," %d V semaphore ops\n", serv_v_ops);
  137.  
  138. #ifdef TIME_CALLDISK
  139.     {
  140.         extern int avgcount; 
  141.         register int i, sum, usum; 
  142.         extern struct timeval hist[], avghist;
  143.         fprintf(stdout,"last 50 times for callDisk (from DISK MESSAGES.remotely):\n");
  144.         sum = usum = 0;
  145.         for(i=0; i<10; i++) {
  146.             sum += hist[i].tv_sec; usum += hist[i].tv_usec;
  147.             sum += hist[i+10].tv_sec; usum += hist[i+10].tv_usec;
  148.             sum += hist[i+20].tv_sec; usum += hist[i+20].tv_usec;
  149.             sum += hist[i+30].tv_sec; usum += hist[i+30].tv_usec;
  150.             sum += hist[i+40].tv_sec; usum += hist[i+40].tv_usec;
  151.             fprintf(stdout,
  152.             "%3.3d.%6.6d  %3.3d.%6.6d  %3.3d.%6.6d  %3.3d.%6.6d %3.3d.%6.6d\n",
  153.             hist[i].tv_sec, hist[i].tv_usec,
  154.             hist[i+10].tv_sec, hist[i+10].tv_usec,
  155.             hist[i+20].tv_sec, hist[i+20].tv_usec,
  156.             hist[i+30].tv_sec, hist[i+30].tv_usec,
  157.             hist[i+40].tv_sec, hist[i+40].tv_usec
  158.             );
  159.         }
  160.         fprintf(stdout, "AVG: last 50: %3.3d.%6.6d, all: %3.3d.%6.6d\n", 
  161.             sum/50, usum/50, avghist.tv_sec/avgcount, avghist.tv_usec/avgcount);
  162.     }
  163. #endif TIME_CALLDISK
  164.  
  165.     if( itx_lrc_lookups > 0) {
  166.         fprintf(stdout, 
  167.         "INTER TRANSACTION PAGE CACHING: %d {PID,LRC} lookups, %d PID finds\n",
  168.                 itx_lrc_lookups, itx_lrc_finds );
  169.         fprintf(stdout, 
  170.         "\t%d out-of-date LRCs, %d page sends skipped (w/ %d disk reads)\n",
  171.                 itx_client_old, itx_client_current, itx_server_foiled);
  172.     }
  173.     
  174.     printMessageStats(stdout, &MsgStats);
  175.  
  176.     ServerTimer.PrintStats();
  177. } /* dumpStats */
  178.  
  179. void
  180. clearStats()
  181. {
  182.     itx_client_current = itx_client_old = itx_server_foiled = 0;
  183.     itx_lrc_lookups = itx_lrc_finds =  0;
  184.  
  185.     cache_hits = cache_misses =0;
  186. #if IO_STATISTICS IS_ENABLED
  187.     IO_DiskReads = IO_DiskWrites = 0;
  188. #endif 
  189.     fast_path_taken = slow_path_taken = disk_requests = 0;
  190.     serv_sleeps = serv_sel_intrs = 0;
  191.     sel_connects = sel_disks = sel_clients = sel_stdin = sel_media =
  192.         sel_dgrams = 0;
  193.  
  194.     serv_v_ops = 0;
  195.     disk_replies_found = disk_replies_kicked = unnecessary_kicks = 0;
  196.     /* DO NOT TOUCH disk_requests_out, threads_awaiting_q -- they are not
  197.      * merely stats 
  198.      */
  199.     { /* TODO: remove */
  200.         extern int loops, loop_spare, loop_ran_ready;
  201.  
  202.         loops = loop_spare = loop_ran_ready =0;
  203.     }
  204.  
  205.     (void) BZERO(&MsgStats, sizeof(MsgStats));
  206. }
  207.  
  208.